package com.me.Hiddo;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;

public class MainScreen extends MyScreen {
			
	private BitmapFont font;
    private Rectangle playRect, creditsRect, settingsRect, exitRect;
    private Vector3 touchPos;
    
	public MainScreen(MyGdxGame game){	
		super(game);
		
		LoadContent();
	}	
		
	public void LoadContent(){
		
		font = new BitmapFont(Gdx.files.internal("fonts/normalFont.fnt"), Gdx.files.internal("fonts/normalFont.png"), false);
		font.setColor(0.0f, 0.0f, 0.0f, 1.0f);

		texture = new Texture(Gdx.files.internal("images/Back.png"));
		
		playRect = new Rectangle(15, 550, 150, 50);
		creditsRect = new Rectangle(15, 450, 150, 50);
		settingsRect= new Rectangle(15, 350, 150, 50);
		exitRect = new Rectangle(15, 250, 150, 50);
	}
		
	@Override
	public void render(float delta) {
	
		Gdx.gl.glClearColor(1, 1, 1, 1);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
	
		camera.update();
		
		batch.setProjectionMatrix(camera.combined);
			
		batch.begin();
		
		batch.draw(texture, 0, Gdx.graphics.getHeight() - texture.getHeight());

		font.draw(batch, "HIDDO", 15, 750);
		font.draw(batch, "Play", 15, 600);
		font.draw(batch, "Credits", 15, 500);
		font.draw(batch, "Settings", 15, 400);
		font.draw(batch, "Exit", 15, 300);
		
		batch.end();	
		

		if(Gdx.input.isTouched()) {
	         touchPos = new Vector3();
	         touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
	         camera.unproject(touchPos);

	         if(playRect.contains(touchPos.x, touchPos.y))
	        	 myGame.setScreen(myGame.gameScreen);
	         
	         //if(creditsRect.contains(touchPos.x, touchPos.y))  
	        	// myGame.setScreen(myGame.gameScreen); 
	         
	         //if(settingsRect.contains(touchPos.x, touchPos.y))  
	        	// myGame.setScreen(myGame.gameScreen); 
	         
	         if(exitRect.contains(touchPos.x, touchPos.y))  
	        	 Gdx.app.exit();
	      }
	}
	
	@Override
	public void resize(int width, int height) {
		super.resize(width, height);
	}
	
}
